/*
 * Copyright (c) 2010 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */
/*
 * This file was generated.
 *  with google-apis-code-generator 1.1.0 (build: 2011-09-09 16:53:41 CDT)
 */

package com.google.api.services.gan;

import com.google.api.services.gan.model.*;
import com.google.api.client.http.ByteArrayContent;
import com.google.api.client.http.HttpMethod;
import com.google.api.client.http.HttpRequest;
import com.google.api.client.http.HttpRequestFactory;
import com.google.api.client.http.HttpRequestInitializer;
import com.google.api.client.http.HttpResponse;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.util.GenericData;
import com.google.api.client.util.Key;

import java.io.IOException;

/**
 * Service definition for Gan (v1beta1).
 *
 * <p>
 * Google Affiliate Network API
 * </p>
 *
 * <p>
 * For more information about this service, see the
 * <a href="" target="_blank">API Documentation</a>
 * </p>
 *
 * @author Google, Inc.
 */
public class Gan extends ApiClient {

  /**
   * Reference to myself so instances of inner classes can find the handle to their service
   * connection.
   */
  final Gan self;

  /**
   * Construct a Gan instance to connect to the Gan service.
   *
   * @param transport A transport to use for subsequent API calls.
   * @param requestInitializer A initializer to use to build requests for subsequent API calls. May be null if no initializer is required.
   * @param jsonFactory A factory to deliver JSON parsers. The choice depends
   *   on the execution environment. Most applications will want to use the
   *   open-source Jackson library, via the factory
   *   com.google.api.client.json.jackson.JacksonFactory.
   *   Android applications will probably want to use the smaller GSON library,
   *   (com.google.api.client.json.gson.GsonFactory).
   */
  public Gan(
      HttpTransport transport,
      HttpRequestInitializer requestInitializer,
      JsonFactory jsonFactory) {
    super("https://www.googleapis.com", "/gan/v1beta1/", transport, requestInitializer, jsonFactory);
    self = this;
  }

  /**
   * Construct a Gan instance to connect to the Gan service.
   *
   * @param transport A transport to use for subsequent API calls.
   * @param jsonFactory A factory to deliver JSON parsers. The choice depends
   *   on the execution environment. Most applications will want to use the
   *   open-source Jackson library, via the factory
   *   com.google.api.client.json.jackson.JacksonFactory.
   *   Android applications will probably want to use the smaller GSON library,
   *   (com.google.api.client.json.gson.GsonFactory).
   */
  public Gan(HttpTransport transport, JsonFactory jsonFactory) {
    this(transport, null, jsonFactory);
  }

  /**
   * Construct a Gan instance to connect to the Gan service.
   *
   * @param appName The application name. This is embedded into the User-Agent string
   * @param transport A transport to use for subsequent API calls.
   * @param jsonFactory A factory to deliver JSON parsers. The choice depends
   *   on the execution environment. Most applications will want to use the
   *   open-source Jackson library, via the factory
   *   com.google.api.client.json.jackson.JacksonFactory.
   *   Android applications will probably want to use the smaller GSON library,
   *   (com.google.api.client.json.gson.GsonFactory).
   */
  public Gan(String appName, HttpTransport transport, JsonFactory jsonFactory) {
    this(transport, null, jsonFactory);
    this.setApplicationName(appName);
  }


  /**
   * An accessor for creating requests from the Advertisers collection.
   *
   * The typical use is:<pre>
   *   {@code Gan gan = new Gan(...);}
   *   {@code Gan.Advertisers.List request = gan.advertisers().list(parameters ...)}</pre>
   *
   * @return the resource collection
   */
  public Advertisers advertisers() {
    return new Advertisers();
  }

  /**
   * An accessor for creating requests from the Advertisers collection.
   *
   * @deprecated (scheduled to be removed in 1.4) Use {@link #advertisers()}
   */
  @Deprecated
  public final Advertisers advertisers = new Advertisers();

  /**
   * The "advertisers" collection of methods.
   */
  public class Advertisers {

    /**
     * Retrieves data about all advertisers that the requesting advertiser/publisher has access to.
     *
     * Create a request for the method "advertisers.list".
     *
     * This request holds the parameters needed by the the gan server.  After setting any optional
     * parameters, call the {@link List#execute()} method to invoke the remote operation.
     *
     * @param role The role of the requester. Valid values: 'advertisers' or 'publishers'.
     * @param roleId The ID of the requesting advertiser or publisher.
     * @return the request
     */
    public List list(String role, String roleId) {
      return new List(role, roleId);
    }

    public class List extends RemoteRequest {

      private static final String REST_PATH = "{role}/{roleId}/advertisers";

      /**
       * Internal constructor.  Use the convenience method instead.
       */
      private List(String role, String roleId) {
        this.role = role;
        this.roleId = roleId;
      }

      /**
       * Sends the "list" request to the Gan server.
       *
       * @return the {@link Advertisers} response
       * @throws IOException if the request fails
       */
      public com.google.api.services.gan.model.Advertisers execute() throws IOException {
        HttpResponse response = executeUnparsed();

        com.google.api.services.gan.model.Advertisers result = jsonParser.parse(
            response, com.google.api.services.gan.model.Advertisers.class);
        result.setResponseHeaders(response.getHeaders());
        return result;

      }

      /**
       * Sends the "list" request to the Gan server and returns the raw {@link HttpResponse}.
       * @return the {@link HttpResponse}
       * @throws IOException if the request fails
       */
      @Override
      public HttpResponse executeUnparsed() throws IOException {
        return super.execute(HttpMethod.GET,
                             REST_PATH);
      }

      /**  The role of the requester. Valid values: 'advertisers' or 'publishers'.
       */
      @Key("role")
      private String role;

      /** The role of the requester. Valid values: 'advertisers' or 'publishers'. */
      public String getRole() {
        return role;
      }

      /** The role of the requester. Valid values: 'advertisers' or 'publishers'. */
      public List setRole(String role) {
        this.role = role;
        return this;
      }

      /**  The ID of the requesting advertiser or publisher.
       */
      @Key("roleId")
      private String roleId;

      /** The ID of the requesting advertiser or publisher. */
      public String getRoleId() {
        return roleId;
      }

      /** The ID of the requesting advertiser or publisher. */
      public List setRoleId(String roleId) {
        this.roleId = roleId;
        return this;
      }

      /**  Filters out all advertisers for which do not have the given relationship status with the
      requesting publisher.
       */
      @Key("relationshipStatus")
      private String relationshipStatus;

      /**
     * Filters out all advertisers for which do not have the given relationship status with the
     * requesting publisher.
     */
      public String getRelationshipStatus() {
        return relationshipStatus;
      }

      /**
     * Filters out all advertisers for which do not have the given relationship status with the
     * requesting publisher.
     */
      public List setRelationshipStatus(String relationshipStatus) {
        this.relationshipStatus = relationshipStatus;
        return this;
      }

      /**  Filters out all advertisers that have a seven day EPC average lower than the given value
      (inclusive). Min value: 0.0. Optional.
       */
      @Key("minSevenDayEpc")
      private Double minSevenDayEpc;

      /**
     * Filters out all advertisers that have a seven day EPC average lower than the given value
     * (inclusive). Min value: 0.0. Optional.
     */
      public Double getMinSevenDayEpc() {
        return minSevenDayEpc;
      }

      /**
     * Filters out all advertisers that have a seven day EPC average lower than the given value
     * (inclusive). Min value: 0.0. Optional.
     */
      public List setMinSevenDayEpc(Double minSevenDayEpc) {
        this.minSevenDayEpc = minSevenDayEpc;
        return this;
      }

      /**  Caret(^) delimted list of advertiser categories. Valid categories are defined here:
      http://www.google.com/support/affiliatenetwork/advertiser/bin/answer.py?hl=en&answer=107581.
      Filters out all advertisers not in one of the given advertiser categories. Optional.
       */
      @Key("advertiserCategory")
      private String advertiserCategory;

      /**
     * Caret(^) delimted list of advertiser categories. Valid categories are defined here:
     * http://www.google.com/support/affiliatenetwork/advertiser/bin/answer.py?hl=en&answer=107581.
     * Filters out all advertisers not in one of the given advertiser categories. Optional.
     */
      public String getAdvertiserCategory() {
        return advertiserCategory;
      }

      /**
     * Caret(^) delimted list of advertiser categories. Valid categories are defined here:
     * http://www.google.com/support/affiliatenetwork/advertiser/bin/answer.py?hl=en&answer=107581.
     * Filters out all advertisers not in one of the given advertiser categories. Optional.
     */
      public List setAdvertiserCategory(String advertiserCategory) {
        this.advertiserCategory = advertiserCategory;
        return this;
      }

      /**  Filters out all advertisers that have a ninety day EPC average lower than the given value
      (inclusive). Min value: 0.0. Optional.
       */
      @Key("minNinetyDayEpc")
      private Double minNinetyDayEpc;

      /**
     * Filters out all advertisers that have a ninety day EPC average lower than the given value
     * (inclusive). Min value: 0.0. Optional.
     */
      public Double getMinNinetyDayEpc() {
        return minNinetyDayEpc;
      }

      /**
     * Filters out all advertisers that have a ninety day EPC average lower than the given value
     * (inclusive). Min value: 0.0. Optional.
     */
      public List setMinNinetyDayEpc(Double minNinetyDayEpc) {
        this.minNinetyDayEpc = minNinetyDayEpc;
        return this;
      }

      /**  The value of 'nextPageToken' from the previous page. Optional.
       */
      @Key("pageToken")
      private String pageToken;

      /** The value of 'nextPageToken' from the previous page. Optional. */
      public String getPageToken() {
        return pageToken;
      }

      /** The value of 'nextPageToken' from the previous page. Optional. */
      public List setPageToken(String pageToken) {
        this.pageToken = pageToken;
        return this;
      }

      /**  Max number of items to return in this page. Optional. Defaults to 20. [minimum: 0] [maximum: 100]
       */
      @Key("maxResults")
      private Integer maxResults;

      /** Max number of items to return in this page. Optional. Defaults to 20. */
      public Integer getMaxResults() {
        return maxResults;
      }

      /** Max number of items to return in this page. Optional. Defaults to 20. */
      public List setMaxResults(Integer maxResults) {
        this.maxResults = maxResults;
        return this;
      }

      /**  A value between 1 and 4, where 1 represents the quartile of advertisers with the lowest ranks and
      4 represents the quartile of advertisers with the highest ranks. Filters out all advertisers with
      a lower rank than the given quartile. For example if a 2 was given only advertisers with a payout
      rank of 25 or higher would be included. Optional. [minimum: 1] [maximum: 4]
       */
      @Key("minPayoutRank")
      private Integer minPayoutRank;

      /**
     * A value between 1 and 4, where 1 represents the quartile of advertisers with the lowest ranks
     * and 4 represents the quartile of advertisers with the highest ranks. Filters out all
     * advertisers with a lower rank than the given quartile. For example if a 2 was given only
     * advertisers with a payout rank of 25 or higher would be included. Optional.
     */
      public Integer getMinPayoutRank() {
        return minPayoutRank;
      }

      /**
     * A value between 1 and 4, where 1 represents the quartile of advertisers with the lowest ranks
     * and 4 represents the quartile of advertisers with the highest ranks. Filters out all
     * advertisers with a lower rank than the given quartile. For example if a 2 was given only
     * advertisers with a payout rank of 25 or higher would be included. Optional.
     */
      public List setMinPayoutRank(Integer minPayoutRank) {
        this.minPayoutRank = minPayoutRank;
        return this;
      }


    }
    /**
     * Retrieves data about a single advertiser if that the requesting advertiser/publisher has access
     * to it. Only publishers can lookup advertisers. Advertisers can request information about
     * themselves by omitting the advertiserId query parameter.
     *
     * Create a request for the method "advertisers.get".
     *
     * This request holds the parameters needed by the the gan server.  After setting any optional
     * parameters, call the {@link Get#execute()} method to invoke the remote operation.
     *
     * @param role The role of the requester. Valid values: 'advertisers' or 'publishers'.
     * @param roleId The ID of the requesting advertiser or publisher.
     * @return the request
     */
    public Get get(String role, String roleId) {
      return new Get(role, roleId);
    }

    public class Get extends RemoteRequest {

      private static final String REST_PATH = "{role}/{roleId}/advertiser";

      /**
       * Internal constructor.  Use the convenience method instead.
       */
      private Get(String role, String roleId) {
        this.role = role;
        this.roleId = roleId;
      }

      /**
       * Sends the "get" request to the Gan server.
       *
       * @return the {@link Advertiser} response
       * @throws IOException if the request fails
       */
      public com.google.api.services.gan.model.Advertiser execute() throws IOException {
        HttpResponse response = executeUnparsed();

        com.google.api.services.gan.model.Advertiser result = jsonParser.parse(
            response, com.google.api.services.gan.model.Advertiser.class);
        result.setResponseHeaders(response.getHeaders());
        return result;

      }

      /**
       * Sends the "get" request to the Gan server and returns the raw {@link HttpResponse}.
       * @return the {@link HttpResponse}
       * @throws IOException if the request fails
       */
      @Override
      public HttpResponse executeUnparsed() throws IOException {
        return super.execute(HttpMethod.GET,
                             REST_PATH);
      }

      /**  The role of the requester. Valid values: 'advertisers' or 'publishers'.
       */
      @Key("role")
      private String role;

      /** The role of the requester. Valid values: 'advertisers' or 'publishers'. */
      public String getRole() {
        return role;
      }

      /** The role of the requester. Valid values: 'advertisers' or 'publishers'. */
      public Get setRole(String role) {
        this.role = role;
        return this;
      }

      /**  The ID of the requesting advertiser or publisher.
       */
      @Key("roleId")
      private String roleId;

      /** The ID of the requesting advertiser or publisher. */
      public String getRoleId() {
        return roleId;
      }

      /** The ID of the requesting advertiser or publisher. */
      public Get setRoleId(String roleId) {
        this.roleId = roleId;
        return this;
      }

      /**  The ID of the advertiser to look up. Optional.
       */
      @Key("advertiserId")
      private String advertiserId;

      /** The ID of the advertiser to look up. Optional. */
      public String getAdvertiserId() {
        return advertiserId;
      }

      /** The ID of the advertiser to look up. Optional. */
      public Get setAdvertiserId(String advertiserId) {
        this.advertiserId = advertiserId;
        return this;
      }


    }

  }

  /**
   * An accessor for creating requests from the CcOffers collection.
   *
   * The typical use is:<pre>
   *   {@code Gan gan = new Gan(...);}
   *   {@code Gan.CcOffers.List request = gan.ccOffers().list(parameters ...)}</pre>
   *
   * @return the resource collection
   */
  public CcOffers ccOffers() {
    return new CcOffers();
  }

  /**
   * An accessor for creating requests from the CcOffers collection.
   *
   * @deprecated (scheduled to be removed in 1.4) Use {@link #ccOffers()}
   */
  @Deprecated
  public final CcOffers ccOffers = new CcOffers();

  /**
   * The "ccOffers" collection of methods.
   */
  public class CcOffers {

    /**
     * Retrieves credit card offers for the given publisher.
     *
     * Create a request for the method "ccOffers.list".
     *
     * This request holds the parameters needed by the the gan server.  After setting any optional
     * parameters, call the {@link List#execute()} method to invoke the remote operation.
     *
     * @param publisher The ID of the publisher in question.
     * @return the request
     */
    public List list(String publisher) {
      return new List(publisher);
    }

    public class List extends RemoteRequest {

      private static final String REST_PATH = "publishers/{publisher}/ccOffers";

      /**
       * Internal constructor.  Use the convenience method instead.
       */
      private List(String publisher) {
        this.publisher = publisher;
      }

      /**
       * Sends the "list" request to the Gan server.
       *
       * @return the {@link CcOffers} response
       * @throws IOException if the request fails
       */
      public com.google.api.services.gan.model.CcOffers execute() throws IOException {
        HttpResponse response = executeUnparsed();

        com.google.api.services.gan.model.CcOffers result = jsonParser.parse(
            response, com.google.api.services.gan.model.CcOffers.class);
        result.setResponseHeaders(response.getHeaders());
        return result;

      }

      /**
       * Sends the "list" request to the Gan server and returns the raw {@link HttpResponse}.
       * @return the {@link HttpResponse}
       * @throws IOException if the request fails
       */
      @Override
      public HttpResponse executeUnparsed() throws IOException {
        return super.execute(HttpMethod.GET,
                             REST_PATH);
      }

      /**  The ID of the publisher in question.
       */
      @Key("publisher")
      private String publisher;

      /** The ID of the publisher in question. */
      public String getPublisher() {
        return publisher;
      }

      /** The ID of the publisher in question. */
      public List setPublisher(String publisher) {
        this.publisher = publisher;
        return this;
      }

      /**  The advertiser ID of a card issuer whose offers to include. Optional, may be repeated.
       */
      @Key("advertiser")
      private java.util.List<String> advertiser;

      /** The advertiser ID of a card issuer whose offers to include. Optional, may be repeated. */
      public java.util.List<String> getAdvertiser() {
        return advertiser;
      }

      /** The advertiser ID of a card issuer whose offers to include. Optional, may be repeated. */
      public List setAdvertiser(java.util.List<String> advertiser) {
        this.advertiser = advertiser;
        return this;
      }

      /**  The set of fields to return.
       */
      @Key("projection")
      private String projection;

      /** The set of fields to return. */
      public String getProjection() {
        return projection;
      }

      /** The set of fields to return. */
      public List setProjection(String projection) {
        this.projection = projection;
        return this;
      }


    }

  }

  /**
   * An accessor for creating requests from the Events collection.
   *
   * The typical use is:<pre>
   *   {@code Gan gan = new Gan(...);}
   *   {@code Gan.Events.List request = gan.events().list(parameters ...)}</pre>
   *
   * @return the resource collection
   */
  public Events events() {
    return new Events();
  }

  /**
   * An accessor for creating requests from the Events collection.
   *
   * @deprecated (scheduled to be removed in 1.4) Use {@link #events()}
   */
  @Deprecated
  public final Events events = new Events();

  /**
   * The "events" collection of methods.
   */
  public class Events {

    /**
     * Retrieves event data for a given advertiser/publisher.
     *
     * Create a request for the method "events.list".
     *
     * This request holds the parameters needed by the the gan server.  After setting any optional
     * parameters, call the {@link List#execute()} method to invoke the remote operation.
     *
     * @param role The role of the requester. Valid values: 'advertisers' or 'publishers'.
     * @param roleId The ID of the requesting advertiser or publisher.
     * @return the request
     */
    public List list(String role, String roleId) {
      return new List(role, roleId);
    }

    public class List extends RemoteRequest {

      private static final String REST_PATH = "{role}/{roleId}/events";

      /**
       * Internal constructor.  Use the convenience method instead.
       */
      private List(String role, String roleId) {
        this.role = role;
        this.roleId = roleId;
      }

      /**
       * Sends the "list" request to the Gan server.
       *
       * @return the {@link Events} response
       * @throws IOException if the request fails
       */
      public com.google.api.services.gan.model.Events execute() throws IOException {
        HttpResponse response = executeUnparsed();

        com.google.api.services.gan.model.Events result = jsonParser.parse(
            response, com.google.api.services.gan.model.Events.class);
        result.setResponseHeaders(response.getHeaders());
        return result;

      }

      /**
       * Sends the "list" request to the Gan server and returns the raw {@link HttpResponse}.
       * @return the {@link HttpResponse}
       * @throws IOException if the request fails
       */
      @Override
      public HttpResponse executeUnparsed() throws IOException {
        return super.execute(HttpMethod.GET,
                             REST_PATH);
      }

      /**  The role of the requester. Valid values: 'advertisers' or 'publishers'.
       */
      @Key("role")
      private String role;

      /** The role of the requester. Valid values: 'advertisers' or 'publishers'. */
      public String getRole() {
        return role;
      }

      /** The role of the requester. Valid values: 'advertisers' or 'publishers'. */
      public List setRole(String role) {
        this.role = role;
        return this;
      }

      /**  The ID of the requesting advertiser or publisher.
       */
      @Key("roleId")
      private String roleId;

      /** The ID of the requesting advertiser or publisher. */
      public String getRoleId() {
        return roleId;
      }

      /** The ID of the requesting advertiser or publisher. */
      public List setRoleId(String roleId) {
        this.roleId = roleId;
        return this;
      }

      /**  Caret(^) delimited list of order IDs. Filters out all events that do not reference one of the
      given order IDs. Optional.
       */
      @Key("orderId")
      private String orderId;

      /**
     * Caret(^) delimited list of order IDs. Filters out all events that do not reference one of the
     * given order IDs. Optional.
     */
      public String getOrderId() {
        return orderId;
      }

      /**
     * Caret(^) delimited list of order IDs. Filters out all events that do not reference one of the
     * given order IDs. Optional.
     */
      public List setOrderId(String orderId) {
        this.orderId = orderId;
        return this;
      }

      /**  Caret(^) delimited list of SKUs. Filters out all events that do not reference one of the given
      SKU. Optional.
       */
      @Key("sku")
      private String sku;

      /**
     * Caret(^) delimited list of SKUs. Filters out all events that do not reference one of the
     * given SKU. Optional.
     */
      public String getSku() {
        return sku;
      }

      /**
     * Caret(^) delimited list of SKUs. Filters out all events that do not reference one of the
     * given SKU. Optional.
     */
      public List setSku(String sku) {
        this.sku = sku;
        return this;
      }

      /**  Filters out all events later than given date. Optional. Defaults to 24 hours after eventMin.
       */
      @Key("eventDateMax")
      private String eventDateMax;

      /**
     * Filters out all events later than given date. Optional. Defaults to 24 hours after eventMin.
     */
      public String getEventDateMax() {
        return eventDateMax;
      }

      /**
     * Filters out all events later than given date. Optional. Defaults to 24 hours after eventMin.
     */
      public List setEventDateMax(String eventDateMax) {
        this.eventDateMax = eventDateMax;
        return this;
      }

      /**  Filters out all events that are not of the given type. Valid values: 'action', 'transaction',
      'charge'. Optional.
       */
      @Key("type")
      private String type;

      /**
     * Filters out all events that are not of the given type. Valid values: 'action', 'transaction',
     * 'charge'. Optional.
     */
      public String getType() {
        return type;
      }

      /**
     * Filters out all events that are not of the given type. Valid values: 'action', 'transaction',
     * 'charge'. Optional.
     */
      public List setType(String type) {
        this.type = type;
        return this;
      }

      /**  Caret(^) delimited list of link IDs. Filters out all events that do not reference one of the given
      link IDs. Optional.
       */
      @Key("linkId")
      private String linkId;

      /**
     * Caret(^) delimited list of link IDs. Filters out all events that do not reference one of the
     * given link IDs. Optional.
     */
      public String getLinkId() {
        return linkId;
      }

      /**
     * Caret(^) delimited list of link IDs. Filters out all events that do not reference one of the
     * given link IDs. Optional.
     */
      public List setLinkId(String linkId) {
        this.linkId = linkId;
        return this;
      }

      /**  Filters out all events that do not have the given status. Valid values: 'active', 'canceled'.
      Optional.
       */
      @Key("status")
      private String status;

      /**
     * Filters out all events that do not have the given status. Valid values: 'active', 'canceled'.
     * Optional.
     */
      public String getStatus() {
        return status;
      }

      /**
     * Filters out all events that do not have the given status. Valid values: 'active', 'canceled'.
     * Optional.
     */
      public List setStatus(String status) {
        this.status = status;
        return this;
      }

      /**  Filters out all events earlier than given date. Optional. Defaults to 24 hours from current
      date/time.
       */
      @Key("eventDateMin")
      private String eventDateMin;

      /**
     * Filters out all events earlier than given date. Optional. Defaults to 24 hours from current
     * date/time.
     */
      public String getEventDateMin() {
        return eventDateMin;
      }

      /**
     * Filters out all events earlier than given date. Optional. Defaults to 24 hours from current
     * date/time.
     */
      public List setEventDateMin(String eventDateMin) {
        this.eventDateMin = eventDateMin;
        return this;
      }

      /**  Caret(^) delimited list of member IDs. Filters out all events that do not reference one of the
      given member IDs. Optional.
       */
      @Key("memberId")
      private String memberId;

      /**
     * Caret(^) delimited list of member IDs. Filters out all events that do not reference one of
     * the given member IDs. Optional.
     */
      public String getMemberId() {
        return memberId;
      }

      /**
     * Caret(^) delimited list of member IDs. Filters out all events that do not reference one of
     * the given member IDs. Optional.
     */
      public List setMemberId(String memberId) {
        this.memberId = memberId;
        return this;
      }

      /**  Max number of offers to return in this page. Optional. Defaults to 20. [minimum: 0] [maximum: 100]
       */
      @Key("maxResults")
      private Integer maxResults;

      /** Max number of offers to return in this page. Optional. Defaults to 20. */
      public Integer getMaxResults() {
        return maxResults;
      }

      /** Max number of offers to return in this page. Optional. Defaults to 20. */
      public List setMaxResults(Integer maxResults) {
        this.maxResults = maxResults;
        return this;
      }

      /**  Caret(^) delimited list of advertiser IDs. Filters out all events that do not reference one of the
      given advertiser IDs. Only used when under publishers role. Optional.
       */
      @Key("advertiserId")
      private String advertiserId;

      /**
     * Caret(^) delimited list of advertiser IDs. Filters out all events that do not reference one
     * of the given advertiser IDs. Only used when under publishers role. Optional.
     */
      public String getAdvertiserId() {
        return advertiserId;
      }

      /**
     * Caret(^) delimited list of advertiser IDs. Filters out all events that do not reference one
     * of the given advertiser IDs. Only used when under publishers role. Optional.
     */
      public List setAdvertiserId(String advertiserId) {
        this.advertiserId = advertiserId;
        return this;
      }

      /**  The value of 'nextPageToken' from the previous page. Optional.
       */
      @Key("pageToken")
      private String pageToken;

      /** The value of 'nextPageToken' from the previous page. Optional. */
      public String getPageToken() {
        return pageToken;
      }

      /** The value of 'nextPageToken' from the previous page. Optional. */
      public List setPageToken(String pageToken) {
        this.pageToken = pageToken;
        return this;
      }

      /**  Caret(^) delimited list of product categories. Filters out all events that do not reference a
      product in one of the given product categories. Optional.
       */
      @Key("productCategory")
      private String productCategory;

      /**
     * Caret(^) delimited list of product categories. Filters out all events that do not reference a
     * product in one of the given product categories. Optional.
     */
      public String getProductCategory() {
        return productCategory;
      }

      /**
     * Caret(^) delimited list of product categories. Filters out all events that do not reference a
     * product in one of the given product categories. Optional.
     */
      public List setProductCategory(String productCategory) {
        this.productCategory = productCategory;
        return this;
      }

      /**  Filters out all charge events that are not of the given charge type. Valid values: 'other',
      'slotting_fee', 'monthly_minimum', 'tier_bonus', 'credit', 'debit'. Optional.
       */
      @Key("chargeType")
      private String chargeType;

      /**
     * Filters out all charge events that are not of the given charge type. Valid values: 'other',
     * 'slotting_fee', 'monthly_minimum', 'tier_bonus', 'credit', 'debit'. Optional.
     */
      public String getChargeType() {
        return chargeType;
      }

      /**
     * Filters out all charge events that are not of the given charge type. Valid values: 'other',
     * 'slotting_fee', 'monthly_minimum', 'tier_bonus', 'credit', 'debit'. Optional.
     */
      public List setChargeType(String chargeType) {
        this.chargeType = chargeType;
        return this;
      }

      /**  Caret(^) delimited list of publisher IDs. Filters out all events that do not reference one of the
      given publishers IDs. Only used when under advertiser role. Optional.
       */
      @Key("publisherId")
      private String publisherId;

      /**
     * Caret(^) delimited list of publisher IDs. Filters out all events that do not reference one of
     * the given publishers IDs. Only used when under advertiser role. Optional.
     */
      public String getPublisherId() {
        return publisherId;
      }

      /**
     * Caret(^) delimited list of publisher IDs. Filters out all events that do not reference one of
     * the given publishers IDs. Only used when under advertiser role. Optional.
     */
      public List setPublisherId(String publisherId) {
        this.publisherId = publisherId;
        return this;
      }


    }

  }

  /**
   * An accessor for creating requests from the Publishers collection.
   *
   * The typical use is:<pre>
   *   {@code Gan gan = new Gan(...);}
   *   {@code Gan.Publishers.List request = gan.publishers().list(parameters ...)}</pre>
   *
   * @return the resource collection
   */
  public Publishers publishers() {
    return new Publishers();
  }

  /**
   * An accessor for creating requests from the Publishers collection.
   *
   * @deprecated (scheduled to be removed in 1.4) Use {@link #publishers()}
   */
  @Deprecated
  public final Publishers publishers = new Publishers();

  /**
   * The "publishers" collection of methods.
   */
  public class Publishers {

    /**
     * Retrieves data about all publishers that the requesting advertiser/publisher has access to.
     *
     * Create a request for the method "publishers.list".
     *
     * This request holds the parameters needed by the the gan server.  After setting any optional
     * parameters, call the {@link List#execute()} method to invoke the remote operation.
     *
     * @param role The role of the requester. Valid values: 'advertisers' or 'publishers'.
     * @param roleId The ID of the requesting advertiser or publisher.
     * @return the request
     */
    public List list(String role, String roleId) {
      return new List(role, roleId);
    }

    public class List extends RemoteRequest {

      private static final String REST_PATH = "{role}/{roleId}/publishers";

      /**
       * Internal constructor.  Use the convenience method instead.
       */
      private List(String role, String roleId) {
        this.role = role;
        this.roleId = roleId;
      }

      /**
       * Sends the "list" request to the Gan server.
       *
       * @return the {@link Publishers} response
       * @throws IOException if the request fails
       */
      public com.google.api.services.gan.model.Publishers execute() throws IOException {
        HttpResponse response = executeUnparsed();

        com.google.api.services.gan.model.Publishers result = jsonParser.parse(
            response, com.google.api.services.gan.model.Publishers.class);
        result.setResponseHeaders(response.getHeaders());
        return result;

      }

      /**
       * Sends the "list" request to the Gan server and returns the raw {@link HttpResponse}.
       * @return the {@link HttpResponse}
       * @throws IOException if the request fails
       */
      @Override
      public HttpResponse executeUnparsed() throws IOException {
        return super.execute(HttpMethod.GET,
                             REST_PATH);
      }

      /**  The role of the requester. Valid values: 'advertisers' or 'publishers'.
       */
      @Key("role")
      private String role;

      /** The role of the requester. Valid values: 'advertisers' or 'publishers'. */
      public String getRole() {
        return role;
      }

      /** The role of the requester. Valid values: 'advertisers' or 'publishers'. */
      public List setRole(String role) {
        this.role = role;
        return this;
      }

      /**  The ID of the requesting advertiser or publisher.
       */
      @Key("roleId")
      private String roleId;

      /** The ID of the requesting advertiser or publisher. */
      public String getRoleId() {
        return roleId;
      }

      /** The ID of the requesting advertiser or publisher. */
      public List setRoleId(String roleId) {
        this.roleId = roleId;
        return this;
      }

      /**  Caret(^) delimted list of publisher categories. Valid categories: (unclassified|community_and_cont
      ent|shopping_and_promotion|loyalty_and_rewards|network|search_specialist|comparison_shopping|email
      ). Filters out all publishers not in one of the given advertiser categories. Optional.
       */
      @Key("publisherCategory")
      private String publisherCategory;

      /**
     * Caret(^) delimted list of publisher categories. Valid categories: (unclassified|community_and
     * _content|shopping_and_promotion|loyalty_and_rewards|network|search_specialist|comparison_shop
     * ping|email). Filters out all publishers not in one of the given advertiser categories.
     * Optional.
     */
      public String getPublisherCategory() {
        return publisherCategory;
      }

      /**
     * Caret(^) delimted list of publisher categories. Valid categories: (unclassified|community_and
     * _content|shopping_and_promotion|loyalty_and_rewards|network|search_specialist|comparison_shop
     * ping|email). Filters out all publishers not in one of the given advertiser categories.
     * Optional.
     */
      public List setPublisherCategory(String publisherCategory) {
        this.publisherCategory = publisherCategory;
        return this;
      }

      /**  Filters out all publishers for which do not have the given relationship status with the requesting
      publisher.
       */
      @Key("relationshipStatus")
      private String relationshipStatus;

      /**
     * Filters out all publishers for which do not have the given relationship status with the
     * requesting publisher.
     */
      public String getRelationshipStatus() {
        return relationshipStatus;
      }

      /**
     * Filters out all publishers for which do not have the given relationship status with the
     * requesting publisher.
     */
      public List setRelationshipStatus(String relationshipStatus) {
        this.relationshipStatus = relationshipStatus;
        return this;
      }

      /**  Filters out all publishers that have a seven day EPC average lower than the given value
      (inclusive). Min value 0.0. Optional.
       */
      @Key("minSevenDayEpc")
      private Double minSevenDayEpc;

      /**
     * Filters out all publishers that have a seven day EPC average lower than the given value
     * (inclusive). Min value 0.0. Optional.
     */
      public Double getMinSevenDayEpc() {
        return minSevenDayEpc;
      }

      /**
     * Filters out all publishers that have a seven day EPC average lower than the given value
     * (inclusive). Min value 0.0. Optional.
     */
      public List setMinSevenDayEpc(Double minSevenDayEpc) {
        this.minSevenDayEpc = minSevenDayEpc;
        return this;
      }

      /**  Filters out all publishers that have a ninety day EPC average lower than the given value
      (inclusive). Min value: 0.0. Optional.
       */
      @Key("minNinetyDayEpc")
      private Double minNinetyDayEpc;

      /**
     * Filters out all publishers that have a ninety day EPC average lower than the given value
     * (inclusive). Min value: 0.0. Optional.
     */
      public Double getMinNinetyDayEpc() {
        return minNinetyDayEpc;
      }

      /**
     * Filters out all publishers that have a ninety day EPC average lower than the given value
     * (inclusive). Min value: 0.0. Optional.
     */
      public List setMinNinetyDayEpc(Double minNinetyDayEpc) {
        this.minNinetyDayEpc = minNinetyDayEpc;
        return this;
      }

      /**  The value of 'nextPageToken' from the previous page. Optional.
       */
      @Key("pageToken")
      private String pageToken;

      /** The value of 'nextPageToken' from the previous page. Optional. */
      public String getPageToken() {
        return pageToken;
      }

      /** The value of 'nextPageToken' from the previous page. Optional. */
      public List setPageToken(String pageToken) {
        this.pageToken = pageToken;
        return this;
      }

      /**  Max number of items to return in this page. Optional. Defaults to 20. [minimum: 0] [maximum: 100]
       */
      @Key("maxResults")
      private Integer maxResults;

      /** Max number of items to return in this page. Optional. Defaults to 20. */
      public Integer getMaxResults() {
        return maxResults;
      }

      /** Max number of items to return in this page. Optional. Defaults to 20. */
      public List setMaxResults(Integer maxResults) {
        this.maxResults = maxResults;
        return this;
      }

      /**  A value between 1 and 4, where 1 represents the quartile of publishers with the lowest ranks and 4
      represents the quartile of publishers with the highest ranks. Filters out all publishers with a
      lower rank than the given quartile. For example if a 2 was given only publishers with a payout
      rank of 25 or higher would be included. Optional. [minimum: 1] [maximum: 4]
       */
      @Key("minPayoutRank")
      private Integer minPayoutRank;

      /**
     * A value between 1 and 4, where 1 represents the quartile of publishers with the lowest ranks
     * and 4 represents the quartile of publishers with the highest ranks. Filters out all
     * publishers with a lower rank than the given quartile. For example if a 2 was given only
     * publishers with a payout rank of 25 or higher would be included. Optional.
     */
      public Integer getMinPayoutRank() {
        return minPayoutRank;
      }

      /**
     * A value between 1 and 4, where 1 represents the quartile of publishers with the lowest ranks
     * and 4 represents the quartile of publishers with the highest ranks. Filters out all
     * publishers with a lower rank than the given quartile. For example if a 2 was given only
     * publishers with a payout rank of 25 or higher would be included. Optional.
     */
      public List setMinPayoutRank(Integer minPayoutRank) {
        this.minPayoutRank = minPayoutRank;
        return this;
      }


    }
    /**
     * Retrieves data about a single advertiser if that the requesting advertiser/publisher has access
     * to it. Only advertisers can look up publishers. Publishers can request information about
     * themselves by omitting the publisherId query parameter.
     *
     * Create a request for the method "publishers.get".
     *
     * This request holds the parameters needed by the the gan server.  After setting any optional
     * parameters, call the {@link Get#execute()} method to invoke the remote operation.
     *
     * @param role The role of the requester. Valid values: 'advertisers' or 'publishers'.
     * @param roleId The ID of the requesting advertiser or publisher.
     * @return the request
     */
    public Get get(String role, String roleId) {
      return new Get(role, roleId);
    }

    public class Get extends RemoteRequest {

      private static final String REST_PATH = "{role}/{roleId}/publisher";

      /**
       * Internal constructor.  Use the convenience method instead.
       */
      private Get(String role, String roleId) {
        this.role = role;
        this.roleId = roleId;
      }

      /**
       * Sends the "get" request to the Gan server.
       *
       * @return the {@link Publisher} response
       * @throws IOException if the request fails
       */
      public com.google.api.services.gan.model.Publisher execute() throws IOException {
        HttpResponse response = executeUnparsed();

        com.google.api.services.gan.model.Publisher result = jsonParser.parse(
            response, com.google.api.services.gan.model.Publisher.class);
        result.setResponseHeaders(response.getHeaders());
        return result;

      }

      /**
       * Sends the "get" request to the Gan server and returns the raw {@link HttpResponse}.
       * @return the {@link HttpResponse}
       * @throws IOException if the request fails
       */
      @Override
      public HttpResponse executeUnparsed() throws IOException {
        return super.execute(HttpMethod.GET,
                             REST_PATH);
      }

      /**  The role of the requester. Valid values: 'advertisers' or 'publishers'.
       */
      @Key("role")
      private String role;

      /** The role of the requester. Valid values: 'advertisers' or 'publishers'. */
      public String getRole() {
        return role;
      }

      /** The role of the requester. Valid values: 'advertisers' or 'publishers'. */
      public Get setRole(String role) {
        this.role = role;
        return this;
      }

      /**  The ID of the requesting advertiser or publisher.
       */
      @Key("roleId")
      private String roleId;

      /** The ID of the requesting advertiser or publisher. */
      public String getRoleId() {
        return roleId;
      }

      /** The ID of the requesting advertiser or publisher. */
      public Get setRoleId(String roleId) {
        this.roleId = roleId;
        return this;
      }

      /**  The ID of the publisher to look up. Optional.
       */
      @Key("publisherId")
      private String publisherId;

      /** The ID of the publisher to look up. Optional. */
      public String getPublisherId() {
        return publisherId;
      }

      /** The ID of the publisher to look up. Optional. */
      public Get setPublisherId(String publisherId) {
        this.publisherId = publisherId;
        return this;
      }


    }

  }



  /**
   * Base class for all service requests.
   *
   * <p>This class is the base for all requests defined by the gan service. It provides methods to
   * build URLs for request objects, execute the the remote call and invoke the parser to return
   * results.</p>
   */
  public abstract class RemoteRequest extends GenericData {
    @Key
    private String fields;

    /**
     * Returns the partial field mask, or <code>null</code> if none is set.
     */
    public String getFields() {
      return fields;
    }

    /**
     * Sets the partial field mask for this request and response.
     */
    public void setFields(String fields) {
      this.fields = fields;
    }

    HttpResponse execute(HttpMethod method, String requestUrl) throws IOException {
      HttpRequest request = self.buildHttpRequest(method, requestUrl, this);
      if (method == HttpMethod.POST) {
        request.setContent(ByteArrayContent.fromString("application/json", " "));
      }
      return request.execute();
    }

    HttpResponse execute(HttpMethod method, String requestUrl, Object body) throws IOException {
      HttpRequest request = self.buildHttpRequest(method, requestUrl, this);
      request.setContent(self.createSerializer(body));
      request.setEnableGZipContent(true);
      return request.execute();
    }

    /**
      * Sends the request to the server and returns the raw {@link HttpResponse}.
      * @return the {@link HttpResponse}
      * @throws IOException if the request fails
    */
    public abstract HttpResponse executeUnparsed() throws IOException;
  }
}
